/*****************************************************************************
*        描述 :
*             文件描述
*        CLR版本:            3.5
*        创建者 :            蒋 光
*        个人域名:           jiangguang.net.cn
*        命名空间名称:       ECP.Utilities
*        文件名:             ConfigurationHelper.cs
*        创建系统时间:       2012/11/2 19:07:08
*        创建年份:           2012
*
/*****************************************************************************/

namespace ECP.Utilities
{
    using System.Configuration;
    using System.Globalization;

    public class ConfigurationHelper
    {
        public static void GetConfig()
        {
            GetConfig(BaseConfiguration.Instance);
        }

        public static void GetConfig(BaseConfiguration configuration)
        {
            configuration.CustomerCompanyName = ConfigurationManager.AppSettings["CustomerCompanyName"];
            configuration.ConfigurationFrom = configuration.GetConfiguration(ConfigurationManager.AppSettings["ConfigurationFrom"]);
            configuration.SoftName = ConfigurationManager.AppSettings["SoftName"];
            configuration.SoftFullName = ConfigurationManager.AppSettings["SoftFullName"];
            configuration.RunMode = configuration.GetRunMode(ConfigurationManager.AppSettings["RunMode"]);
            configuration.RootMenuID = ConfigurationManager.AppSettings["RootMenuID"];
            configuration.CurrentLanguage = ConfigurationManager.AppSettings["CurrentLanguage"];
            configuration.Version = ConfigurationManager.AppSettings["Version"];
            configuration.CommonWebService = ConfigurationManager.AppSettings["CommonWebService"];
            configuration.WebService = ConfigurationManager.AppSettings["WebService"];
            configuration.FileWebService = ConfigurationManager.AppSettings["FileWebService"];
            configuration.WorkReportWebService = ConfigurationManager.AppSettings["WorkReportWebService"];
            configuration.WebServiceUsername = ConfigurationManager.AppSettings["WebServiceUsername"];
            configuration.WebServicePassword = ConfigurationManager.AppSettings["WebServicePassword"];
            configuration.UseScopeAdmin = string.Compare(ConfigurationManager.AppSettings["UseScopeAdmin"], "TRUE", true, CultureInfo.CurrentCulture) == 0;
            configuration.UseLicensedPermission = string.Compare(ConfigurationManager.AppSettings["UseLicensedPermission"], "TRUE", true, CultureInfo.CurrentCulture) == 0;
            configuration.ServiceFactory = ConfigurationManager.AppSettings["ServiceFactory"];
            configuration.ServicePath = ConfigurationManager.AppSettings["ServicePath"];
            configuration.DbHelperClass = ConfigurationManager.AppSettings["DbHelperClass"];
            configuration.DbHelperAssmely = ConfigurationManager.AppSettings["DbHelperAssmely"];
            configuration.RecordLog = string.Compare(ConfigurationManager.AppSettings["RecordLog"], "TRUE", true, CultureInfo.CurrentCulture) == 0;
            configuration.LoginAssembly = ConfigurationManager.AppSettings["LoginAssembly"];
            configuration.LoginForm = ConfigurationManager.AppSettings["LoginForm"];
            configuration.MainForm = ConfigurationManager.AppSettings["MainForm"];
            configuration.LoadUser = string.Compare(ConfigurationManager.AppSettings["LoadUser"], "TRUE", true, CultureInfo.CurrentCulture) == 0;
            configuration.AllowUserRegister = string.Compare(ConfigurationManager.AppSettings["AllowUserRegister"], "TRUE", true, CultureInfo.CurrentCulture) == 0;
            configuration.DbConnectionString = ConfigurationManager.AppSettings["DbConnectionString"];
            configuration.DataBaseType = configuration.GetDataBaseType(ConfigurationManager.AppSettings["DataBaseType"]);
            configuration.ServerName = ConfigurationManager.AppSettings["ServerName"];
            configuration.DataBase = ConfigurationManager.AppSettings["DataBase"];
            configuration.TrustLink = string.Compare(ConfigurationManager.AppSettings["TrustLink"], "YES", true, CultureInfo.CurrentCulture) == 0;
            configuration.Username = ConfigurationManager.AppSettings["Username"];
            configuration.Password = ConfigurationManager.AppSettings["Password"];
            string str = ConfigurationManager.AppSettings["MaxPoolSize"];
            if (!string.IsNullOrEmpty(str))
            {
                configuration.MaxPoolSize = int.Parse(str, CultureInfo.CurrentCulture);
            }
            string str2 = ConfigurationManager.AppSettings["MinPoolSize"];
            if (!string.IsNullOrEmpty(str2))
            {
                configuration.MinPoolSize = int.Parse(str2, CultureInfo.CurrentCulture);
            }
            configuration.RegisterKey = ConfigurationManager.AppSettings["RegisterKey"];
        }
    }
}